﻿using System;
using System.IO;
using System.Windows.Forms;

public class LocalFileManager
{
    public static void LoadLocalDirectory(TreeNodeCollection nodes, string folderPath)
    {
        // 获取当前目录下的所有文件和文件夹
        var folders = Directory.GetDirectories(folderPath);
        var files = Directory.GetFiles(folderPath);

        // 加载文件夹节点
        foreach (var folder in folders)
        {
            var folderNode = new TreeNode(Path.GetFileName(folder))
            {
                Tag = folder
            };
            LoadLocalDirectory(folderNode.Nodes, folder); // 递归加载子目录
            nodes.Add(folderNode);
        }

        // 加载文件节点
        foreach (var file in files)
        {
            var fileNode = new TreeNode(Path.GetFileName(file))
            {
                Tag = file
            };
            nodes.Add(fileNode);
        }
    }
}

